/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.za.cput.hotelbooking.services.crud.impl;

import ac.za.cput.hotelbooking.model.Booking;
import ac.za.cput.hotelbooking.repository.GenericDAO;
import ac.za.cput.hotelbooking.services.crud.BookingCrudService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author ASUS
 */
@Service("bookingCrudService")
@Transactional
public class BookingCrudServiceImpl implements BookingCrudService{
    @Autowired
    private GenericDAO<Booking> dao;
    
    public final void setDao(final GenericDAO< Booking> daoToSet) {
        this.dao = daoToSet;
        this.dao.setClazz(Booking.class);
    }

    @Override
    public Booking findById(Long id) {
        setDao(dao);
        return dao.findById(id);
    }

    @Override
    public List<Booking> findAll() {
        setDao(dao);
        return dao.findAll();
    }

    @Override
    public void persist(Booking entity) {
        setDao(dao);
        dao.persist(entity);
    }

    @Override
    public void merge(Booking entity) {
        setDao(dao);
        dao.merge(entity);
    }

    @Override
    public void remove(Booking entity) {
        setDao(dao);
        dao.remove(entity);
    }

    @Override
    public void removeById(Long entityId) {
        setDao(dao);
        dao.removeById(entityId);
    }

    @Override
    public List<Booking> findInRange(int firstResult, int maxResults) {
        setDao(dao);
        return dao.findInRange(firstResult, maxResults);
    }

    @Override
    public long count() {
        setDao(dao);
       return dao.count();
    }

    @Override
    public Booking getByPropertyName(String name, String value) {
        setDao(dao);
        return dao.getByPropertyName(name, value);
    }

    @Override
    public List<Booking> getEntitiesByProperName(String name, String value) {
        setDao(dao);
        return dao.getEntitiesByProperName(name, value);
    }
    
}
